var baseconfig = {};

if (process.env.NODE_ENV === 'development') {
	baseconfig = {
		server: 'https://tool.imyxuan.site/api' // 开发环境development
	}
} else if (process.env.NODE_ENV === 'production') {
	baseconfig = {
		server: 'https://tool.imyxuan.site/api' // 生产环境production
	}
}

function Theme() {

	console.log(this.$mp.page.route)
	if (this.$mp.page.route == 'pages/home/Home') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Home
		});
	} else if (this.$mp.page.route == 'pages/category/Category') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Category
		});
	} else if (this.$mp.page.route == 'pages/mine/Mine') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Mine
		});
	} else if (this.$mp.page.route == 'pages/mine/setup/Setup') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Setup
		});
	} else if (this.$mp.page.route == 'pages/category/whole/Whole') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Whole
		});
	} else if (this.$mp.page.route == 'pages/home/add-collection/AddCollection') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.AddCollection
		});
	} else if (this.$mp.page.route == 'pages/mine/synchronization/Synchronization') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Synchronization
		});
	} else if (this.$mp.page.route == 'pages/mine/theme/Theme') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Theme
		});
	} else if (this.$mp.page.route == 'pages/mine/my-account/MyAccount') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.MyAccount
		});
	} else if (this.$mp.page.route == 'pages/mine/my-account/login/Login') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Login
		});
	} else if (this.$mp.page.route == 'pages/mine/my-account/register/Register') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Register
		});
	} else if (this.$mp.page.route == 'pages/tools/qrcode-tool/QrcodeTool') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.QrcodeTool
		});
	} else if (this.$mp.page.route == 'pages/tools/qrcode-tool/code/Code') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Code
		});
	} else if (this.$mp.page.route == 'pages/tools/money-tool/MoneyTool') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.MoneyTool
		});
	} else if (this.$mp.page.route == 'pages/tools/date-tool/DateTool') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.DateTool
		});
	} else if (this.$mp.page.route == 'pages/tools/painting-tool/PaintingTool') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.PaintingTool
		});
	} else if (this.$mp.page.route == 'pages/tools/barrage-tool/BarrageTool') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.BarrageTool
		});
	} else if (this.$mp.page.route == 'pages/tools/picture-tool/PictureTool') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.PictureTool
		});
	} else if (this.$mp.page.route == 'pages/category/search/Search') {
		uni.setNavigationBarTitle({
			title: this.$i18n.messages[this.$i18n.locale].nav.Search
		});
	}

	// 修改底部导航
	uni.setTabBarItem({
		index: 0,
		text: this.$i18n.messages[this.$i18n.locale].tabBar.Home
	});
	uni.setTabBarItem({
		index: 1,
		text: this.$i18n.messages[this.$i18n.locale].tabBar.Category
	});
	uni.setTabBarItem({
		index: 2,
		text: this.$i18n.messages[this.$i18n.locale].tabBar.Mine
	});

	uni.getStorage({
		key: 'theme',
		success: (res) => {

			switch (res.data.theme) {
				case 'dark':

					uni.setTabBarStyle({
						selectedColor: '#ffffff',
						backgroundColor: '#1C1C1C',
					})

					uni.setTabBarItem({
						index: 0,
						selectedIconPath: '/static/images/tabbar/dark/shouye.png'
					})
					uni.setTabBarItem({
						index: 1,
						selectedIconPath: "/static/images/tabbar/dark/fenlei.png",
					})
					uni.setTabBarItem({
						index: 2,
						selectedIconPath: "/static/images/tabbar/dark/wode-wodefensi.png",
					})

					uni.setNavigationBarColor({
						frontColor: '#ffffff',
						backgroundColor: '#1C1C1C',
					})

					break;
				case 'light':

					uni.setTabBarStyle({
						selectedColor: '#0081FF',
						backgroundColor: '#ffffff',
					});

					uni.setTabBarItem({
						index: 0,
						selectedIconPath: '/static/images/tabbar/light/shouye.png'
					})
					uni.setTabBarItem({
						index: 1,
						selectedIconPath: "/static/images/tabbar/light/fenlei.png",
					})
					uni.setTabBarItem({
						index: 2,
						selectedIconPath: "/static/images/tabbar/light/wode-wodefensi.png",
					})

					uni.setNavigationBarColor({
						frontColor: '#ffffff',
						backgroundColor: '#0081FF',
					})
					break;
				case 'daisies':

					uni.setTabBarStyle({
						selectedColor: '#D0D32A',
						backgroundColor: '#ffffff',
					});

					uni.setTabBarItem({
						index: 0,
						selectedIconPath: '/static/images/tabbar/daisies/shouye.png'
					})
					uni.setTabBarItem({
						index: 1,
						selectedIconPath: "/static/images/tabbar/daisies/fenlei.png",
					})
					uni.setTabBarItem({
						index: 2,
						selectedIconPath: "/static/images/tabbar/daisies/wode-wodefensi.png",
					})

					uni.setNavigationBarColor({
						frontColor: '#ffffff',
						backgroundColor: '#D0D32A',
					})

					break;
				case 'orange':

					uni.setTabBarStyle({
						selectedColor: '#FF9703',
						backgroundColor: '#ffffff',
					});

					uni.setTabBarItem({
						index: 0,
						selectedIconPath: '/static/images/tabbar/orange/shouye.png'
					})
					uni.setTabBarItem({
						index: 1,
						selectedIconPath: "/static/images/tabbar/orange/fenlei.png",
					})
					uni.setTabBarItem({
						index: 2,
						selectedIconPath: "/static/images/tabbar/orange/wode-wodefensi.png",
					})

					uni.setNavigationBarColor({
						frontColor: '#ffffff',
						backgroundColor: '#FF9703',
					})
					break;
				case 'flower':

					uni.setTabBarStyle({
						selectedColor: '#F2A8B7',
						backgroundColor: '#ffffff',
					});

					uni.setTabBarItem({
						index: 0,
						selectedIconPath: '/static/images/tabbar/flower/shouye.png'
					})
					uni.setTabBarItem({
						index: 1,
						selectedIconPath: "/static/images/tabbar/flower/fenlei.png",
					})
					uni.setTabBarItem({
						index: 2,
						selectedIconPath: "/static/images/tabbar/flower/wode-wodefensi.png",
					})

					uni.setNavigationBarColor({
						frontColor: '#ffffff',
						backgroundColor: '#F2A8B7',
					})
					break;
				case 'spring':

					uni.setTabBarStyle({
						selectedColor: '#4CB050',
						backgroundColor: '#ffffff',
					});

					uni.setTabBarItem({
						index: 0,
						selectedIconPath: '/static/images/tabbar/spring/shouye.png'
					})
					uni.setTabBarItem({
						index: 1,
						selectedIconPath: "/static/images/tabbar/spring/fenlei.png",
					})
					uni.setTabBarItem({
						index: 2,
						selectedIconPath: "/static/images/tabbar/spring/wode-wodefensi.png",
					})

					uni.setNavigationBarColor({
						frontColor: '#ffffff',
						backgroundColor: '#4CB050',
					})

					break;
				case 'summer':

					uni.setTabBarStyle({
						selectedColor: '#BF3743',
						backgroundColor: '#ffffff',
					});

					uni.setTabBarItem({
						index: 0,
						selectedIconPath: '/static/images/tabbar/summer/shouye.png'
					})
					uni.setTabBarItem({
						index: 1,
						selectedIconPath: "/static/images/tabbar/summer/fenlei.png",
					})
					uni.setTabBarItem({
						index: 2,
						selectedIconPath: "/static/images/tabbar/summer/wode-wodefensi.png",
					})

					uni.setNavigationBarColor({
						frontColor: '#ffffff',
						backgroundColor: '#BF3743',
					})

					break;
			}
		}
	})
}

export {
	baseconfig,
	Theme
};
